#pragma once
#include "gtest/gtest.h"
#include "DataStructure/Input/Property/BeamSectionStandardTypes.h"
#include "../Interface/BarSectionFormulaCalculatorFactory.h"
#include "../Bar/Box1SectionFormulaCalculator.h"

using SG::Algebra::Point;
using namespace SG::DataStructure::FEM;
using SG::FEMSolver::Element::BarSectionFormulaCalculatorFactory;
using SG::FEMSolver::Element::Box1SectionFormulaCalculator;

// 将 BarSectionFormulaCalculatorFactory 生成对象测试放置在具体截面属性计算中
TEST (BarSectionFormulaCalculatorFactoryTest, Box1SectionCalculatorCreate)
{
    // Test data
    auto calculatorPtr = BarSectionFormulaCalculatorFactory::Create (BeamSectionStandardTypes::BEAMSECTYPE_BOX1);
    auto box1CalculatorPtr = dynamic_cast<Box1SectionFormulaCalculator*> (calculatorPtr.get ());

    // Check
    ASSERT_TRUE (nullptr != box1CalculatorPtr);
}

// Box1 截面属性计算测试
TEST (BarSectionFormulaCalculatorTest, Box1Section)
{
    // Input data
    PBARLData section;
    section.m_id  = 2;
    section.m_mId = 3;
    section.SetGroup ("MSCBML0");
    section.SetBeamSectionStandardTypes (BeamSectionStandardTypes::BEAMSECTYPE_BOX1);
    section.m_dimension = {6.0, 7.0, 3.0, 2.5, 1.0, 2.0};
    section.m_nsm = 10.0;

    // Test data
    Box1SectionFormulaCalculator calculator;
    PBARData propertyTest;
    Point centroidTest;
    calculator.Compute (section, _OUT propertyTest, _OUT centroidTest);

    // Target data
    PBARData propertyTarget;
    propertyTarget.m_id  = 2;
    propertyTarget.m_mId = 3;
    propertyTarget.m_A   = 37.5;
    // propertyTarget.m_yS = 0.0;  // ToDo（正确值为：3.5681818）
    // propertyTarget.m_zS = 0.0;  // ToDo（正确值为：2.5）
    // propertyTarget.m_yC  = 3.53;
    // propertyTarget.m_zC  = 2.9400001;
    propertyTarget.m_I1  = 170.34125;
    propertyTarget.m_I2  = 121.365;
    propertyTarget.m_I12 = 0.63;
    propertyTarget.m_J   = 151.2209;
    propertyTarget.m_K1  = 0.12;
    propertyTarget.m_K2  = 0.44;
    propertyTarget.m_NSM = 10.0;
    propertyTarget.m_FE  = 0.0;
    propertyTarget.SetStressPoints ({3.47, 3.06, -3.53, 3.06, -3.53, -2.94, 3.47, -2.94});
    Point centroidTarget;

    // Check
    ASSERT_TRUE (propertyTarget == propertyTest);
    ASSERT_TRUE (centroidTarget == centroidTest);
}